task import_cars: :environment do
    @car_brands = CarBrand.all
    @car_brands.destroy_all
 
    file = "#{Rails.root}/public/car_brands.xlsx" # 将文本路径赋给对象  
    if File.exists?(file)  
      # 打开文本赋值给xlsx对象，将文本第一列赋值给对象sheet  
      xlsx       = Roo::Spreadsheet.open(file, extension: :xlsx)  
      sheet      = xlsx.sheet(0)  
   
      # 这里将读取出来的数据更新到数据表中  

      sheet.row(1).size.times do |c|
        @brand = sheet.column(c+1)[0]
        @car_brand = CarBrand.create(name: @brand)
        @column_rmnils = sheet.column(c+1).reject { |a| a.nil? }
        @models = @column_rmnils[1..@column_rmnils.size]
        @models.each do |m|
          @car_model = CarModel.create(car_brand_id: @car_brand.id, name: m)
        end
      end

    end  

   
end